<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Trang phải</title>


<link href="style/cs1.css" rel="stylesheet" type="text/css" />
</head>

<body>


<table width="200" border="0" cellspacing="0" cellpadding="0">
  <tr>
   
    <td height="36" class="giua">Đăng nhập</td>

  </tr>
</table>
<table width="200" border="0" cellspacing="0" cellpadding="0" class="bangduoi">
  <tr>
    <td align="center">
    <?php
	include("config/config.php");
	if(isset($_POST["user"])&&isset($_POST["pass"]))
	{
		$user = addslashes($_POST["user"]);
		$pass = mysql_escape_string(md5(md5($_POST["pass"])));
	$lenh = "select * from khachhang where user ='$user' and matkhau = '$pass'";
	$kq = mysql_query($lenh);
	$n = mysql_num_rows($kq);
	if($n > 0)
	{
		//khi dung $_SESSION phải khai bao session_start() ở đầu trang web
		$_SESSION["user"]=$user;
		?>
      <script>
		alert('Đăng nhập thành công!');
		</script>
        <?php
		
	}
	else
	{
		?>
      <script>
		alert('Đăng nhập thất bại!');
		</script>
        <?php
	}
	
	}
	
    if(!$_SESSION["user"])
	{
    echo"<form id='form1' name='form1' method='post' action=''>
  <table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>
    <tr>
      <td width='65' height='30' class='khoangcachdangnhap'>User</td>
      <td width='135' height='30'><label for='user'></label>
      <input name='user' type='text' class='odangnhap' id='user' /></td>
    </tr>
    <tr>
      <td height='30' class='khoangcachdangnhap'>Pass</td>
      <td height='30'><label for='pass'></label>
      <input name='pass' type='password' class='odangnhap' id='pass' /></td>
    </tr>
    <tr>
      <td height='30' colspan='2' align='center'><input name='dn' type='submit' class='nutdangnhap' id='dn' value='Đăng nhập' /><br/><a href='index.php?act=dk'>Đăng Ký </a> || <a href='index.php?act=qmk'> Quên Mật Khẩu </a></td>
    </tr>
	<tr>
	<td>&nbsp;</td>
	</tr>
  </table>
</form>";
	}
	else
	{
		$lenh2 = "select * from khachhang where user = '".$_SESSION["user"]."'";
		
		$kq2 = mysql_query($lenh2);
		$row2 = mysql_fetch_array($kq2);
		$Macv = $row2["Macv"];
		if($Macv==0)
		{
			echo "Chào ".$row2["user"]."<br/>";
			echo"<a href='thanhvien/thoat.php'>Thoát</a>";	
		}
		else
		{
			echo "Chào ".$row2["user"]."<br/>";
			echo"<a href='thanhvien/thoat.php'>Thoát</a>"."|";	
			echo"<a href='quantri/indexqt.php'>Quản Trị</a>";	
	
		}
	}
?>

    </td>
  </tr>
</table>

<table width="200" border="0" cellspacing="0" cellpadding="0">
  <tr>
  
    <td height="36" class="giua">Hỗ trợ trực tuyến</td>
 
  </tr>
</table>
<table width="200" border="0" cellspacing="0" cellpadding="0" class="bangduoi">
  <tr>
    <td align="center">
    <b>Anh Phước</b></br><a href="ymsgr:sendim?anhphuoc7373" title="Anh Phuoc"><img alt="" src="http://opi.yahoo.com/online?u=anhphuoc7373&amp;m=g&amp;t=2"border="0" /></a></br> 
    <b>Văn Bình</b></br><a href="ymsgr:sendim?vanbinh_uit" title="Van Binh"><img alt="" src="http://opi.yahoo.com/online?u=vanbinh_uit&amp;m=g&amp;t=2"border="0" /></a></br>
    <b>Trung Hiếu</b></br><a href="ymsgr:sendim?lamongiumdi" title="Trung Hieu"><img alt="" src="http://opi.yahoo.com/online?u=lamongiumdi&amp;m=g&amp;t=2"border="0" /></a></br>
    </td>
  </tr>
</table>

<table width="200" border="0" cellspacing="0" cellpadding="0">
  <tr>

    <td height="36" class="giua">Thống kê</td>

  </tr>
</table>
<table width="200" border="0" cellspacing="0" cellpadding="0" class="bangduoi">
  <tr>
    <td style="text-align:center">
    <span>Số Người Truy Cập</span>
        <p class="count"><a href="http://www.amazingcounter.com"><img border="0" src="http://cb.amazingcounters.com/counter.php?i=2964771&c=8894626" alt="msn spaces analyzer" /></a></p>
        <span>Số Người Online</span>                        
        <p class="count"><script id="_waueb0">var _wau = _wau || []; _wau.push(["small", "3f8bar73qtzo", "eb0"]);(function() { var s=document.createElement("script"); s.async=true; s.src="http://widgets.amung.us/small.js";document.getElementsByTagName("head")[0].appendChild(s);})();</script>
    </td>
  </tr>
</table>

<table width="200" border="0" cellspacing="0" cellpadding="0">
  <tr>
    
    <td height="36" class="giua">Thông tin cần biết</td>
   
  </tr>
</table>
<table width="200" border="0" cellspacing="0" cellpadding="0" class="bangduoi">
  <tr>
   <td>
   <iframe frameborder="0" marginwidth="0" marginheight="0" src="http://www.thienduongweb.com/tool/weather/?size=100%&fsize=12&bg=images/bg.png&repeat=repeat-x&r=1&w=1&g=1&col=1&d=0" width="100%" height="310" scrolling="no"></iframe>
   </td>
  </tr>
</table>







</body>
</html>